<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_content
 *
 * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

// Create a shortcut for params.
$params = &$this->item->params;
$images = json_decode($this->item->images);
$canEdit = $this->item->params->get('access-edit');
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
$info = $this->item->params->get('info_block_position', 0);
JHtml::_('behavior.tooltip');
JHtml::_('behavior.framework');

$n = $this->item->catid;
$db = &JFactory::getDBO();
$query = 'select * from #__categories where id="'.$n.'" and published=1';
$db->setQuery( $query );
$category = $db->loadObjectList();
?>

<table border="0" width="100%">
   <caption><?php echo $category[0]->title; ?></caption>
   <thead>
   		<tr>
        	<td class="contentcategory" colspan="4"><?php echo $category[0]->description; ?></td>
        </tr>
   </thead>
   <thead>
        <tr>
             <th>No.</th>
             <th>Vacancy title</th>
             <th>Property name</th>
             <th>Logo</th>
        </tr>
   </thead>
   <tbody>
   <?php
   $query0 = 'select * from #__content where catid="'.$n.'" and state=1 order by id asc';
   $db->setQuery( $query0 );
   $allcontent = $db->loadObjectList();
   for($i=0;$i<count($allcontent);$i++){
	   	$logo_id = $allcontent[$i]->logo_id;
	   	$querylogo_id = 'select * from #__banners where id="'.$allcontent[$i]->logo_id.'" and state=1';
		$db->setQuery( $querylogo_id );
		$logo_ids = $db->loadObjectList();
		
		$positionimage = $logo_ids[0]->params;	
	   	$logoimage0=explode('imageurl":"', $positionimage); 
	   	$logoimage1=$logoimage0[1];
	   	$logoimage2=explode('","',$logoimage1);
	   	$logoimage3=str_replace('\/','/',$logoimage2[0]);
	   
   ?>
      <tr>
         <td class="number"><?php echo $i+1;?></td>
         <td>
         <a href="<?php echo $this->baseurl ?>/index.php?option=com_content&view=article&id=<?php echo $allcontent[$i]->id; ?>&Itemid=134"> 
            <?php echo $allcontent[$i]->title; ?>
         </a>
         </td>
         <td><?php echo $logo_ids[0]->name;?></td>
         <td class="logoimg"><a target="_blank" href="<?php echo $logo_ids[0]->clickurl;?>"><img src="<?php echo $logoimage3;?>" /></a></td>
      </tr>
   <?php
   }
   ?>
   </tbody>
</table>
